0ea77dfbbe0f21a239d193887cfc92af6eb37adb,library/src/main/java/com/xxxifan/devbox/library/widget/PinchImageView.java,PinchImageView,doubleTap,#number#number#,675

Before Change


    //当当�缩放比例�于1,�击放大到1
    //当当�缩放比例等于MaxScale,�击缩�到�幕大�
    private void doubleTap(float x, float y) {
        if (getDrawable() == null) {
            return;
        }
        //获�第一层��矩阵
        Matrix innerMatrix = getInnerMatrix();
        //当�总的缩放比例
        float innerScale = MathUtils.getMatrixScale(innerMatrix)[0];
        float outerScale = MathUtils.getMatrixScale(mOuterMatrix)[0];
        float currentScale = innerScale * outerScale;
        //控件大�
        float displayWidth = getMeasuredWidth();
        float displayHeight = getMeasuredHeight();
        //最大放大大�
        float maxScale = getMaxScale();
        //接下��放大的大�
        float nextScale = calculateNextScale(innerScale, outerScale);
        //如果接下�放大大于最大值或者�于fit center值,则�边界
        if (nextScale < innerScale) {
            nextScale = innerScale;
        } else if (nextScale > maxScale) {
            nextScale = maxScale;
        }
        //缩放动画�始矩阵为当�矩阵值
        Matrix animStart = new Matrix(mOuterMatrix);
        //开始计算缩放动画的结果矩阵
        Matrix animEnd = new Matrix(mOuterMatrix);
        //计算还需缩放的�数
        animEnd.postScale(nextScale / currentScale, nextScale / currentScale, x, y);
        //将放大点移动到控件中心
        animEnd.postTranslate(displayWidth / 2 - x, displayHeight / 2 - y);
        //得到放大之�的图片方框
        Matrix testMatrix = new Matrix(innerMatrix);
        testMatrix.postConcat(animEnd);
        RectF testBound = new RectF(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
        testMatrix.mapRect(testBound);
        //修正�置
        float postX = 0;

After Change


     * @see #getMaxScale()
     */
    private void doubleTap(float x, float y) {
        if (!isReady()) {
            return;
        }
        //获�第一层��矩阵
        Matrix innerMatrix = MathUtils.matrixTake();
        getInnerMatrix(innerMatrix);
        //当�总的缩放比例
        float innerScale = MathUtils.getMatrixScale(innerMatrix)[0];
        float outerScale = MathUtils.getMatrixScale(mOuterMatrix)[0];
        float currentScale = innerScale * outerScale;
        //控件大�
        float displayWidth = getWidth();
        float displayHeight = getHeight();
        //最大放大大�
        float maxScale = getMaxScale();
        //接下��放大的大�
        float nextScale = calculateNextScale(innerScale, outerScale);
        //如果接下�放大大于最大值或者�于fit center值,则�边界
        if (nextScale > maxScale) {
            nextScale = maxScale;
        }
        if (nextScale < innerScale) {
            nextScale = innerScale;
        }
        //开始计算缩放动画的结果矩阵
        Matrix animEnd = MathUtils.matrixTake(mOuterMatrix);
        //计算还需缩放的�数
        animEnd.postScale(nextScale / currentScale, nextScale / currentScale, x, y);
        //将放大点移动到控件中心
        animEnd.postTranslate(displayWidth / 2f - x, displayHeight / 2f - y);
        //得到放大之�的图片方框
        Matrix testMatrix = MathUtils.matrixTake(innerMatrix);
        testMatrix.postConcat(animEnd);
        RectF testBound = MathUtils.rectFTake(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
        testMatrix.mapRect(testBound);
        //修正�置
        float postX = 0;
        float postY = 0;
        if (testBound.right - testBound.left < displayWidth) {
            postX = displayWidth / 2f - (testBound.right + testBound.left) / 2f;
        } else if (testBound.left > 0) {
            postX = -testBound.left;
        } else if (testBound.right < displayWidth) {
            postX = displayWidth - testBound.right;
        }
        if (testBound.bottom - testBound.top < displayHeight) {
            postY = displayHeight / 2f - (testBound.bottom + testBound.top) / 2f;
        } else if (testBound.top > 0) {
            postY = -testBound.top;
        } else if (testBound.bottom < displayHeight) {
            postY = displayHeight - testBound.bottom;
        }
        //应用修正�置
        animEnd.postTranslate(postX, postY);
        //清�当��能正在执行的动画
        cancelAllAnimator();
        //�动矩阵动画
        mScaleAnimator = new ScaleAnimator(mOuterMatrix, animEnd);
        mScaleAnimator.start();
        //清�临时��
        MathUtils.rectFGiven(testBound);
        MathUtils.matrixGiven(testMatrix);
        MathUtils.matrixGiven(animEnd);
        MathUtils.matrixGiven(innerMatrix);